/*
 * @Author: biankai
 * @Date: 2021-04-19 18:47:04
 * @LastEditTime: 2021-11-10 14:39:03
 * @LastEditors: biankai
 * @FilePath: /gitee/devops_service/src/controllers/jenkins/job.controller.ts
 */
import { Controller, Inject, Get, Query, Param, Post, Put, Delete, Body } from '@nestjs/common';
import { ApiCreatedResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
import { JobService } from '../../services/jenkins/job.service';

@ApiTags('Jenkins-job')
@Controller('jenkins/job')
export class JobController {
    constructor(@Inject(JobService) private readonly jobService: JobService) {
    }

    @ApiOperation({ summary: '获取', description: '说明 : 调用此接口,可获取' })
    @ApiCreatedResponse({
        description: 'The record has been successfully created.',
    })
    @Get('/jobList')
    async jobList() {
        return await this.jobService.jobList()
    }

    @ApiOperation({ summary: '获取', description: '说明 : 调用此接口,可获取' })
    @Get(':jobName')
    async jobGet(@Param('jobName') jobName) {
        return await this.jobService.jobGet(jobName)
    }

    @ApiOperation({ summary: '获取', description: '说明 : 调用此接口,可新增' })
    @Post('/jobCreate')
    async jobCreate(@Query('jobName') jobName, @Body('configxml') configxml) {
        return await this.jobService.jobCreate(jobName, configxml)
    }

    @ApiOperation({ summary: '修改', description: '说明 : 调用此接口,可修改' })
    @Put('/jobConfig/:jobName')
    async jobConfig(@Param('jobName') jobName, @Body('configxml') configxml) {
        return await this.jobService.jobSetConfig(jobName, configxml)
    }

    @ApiOperation({ summary: '修改', description: '说明 : 调用此接口,可修改' })
    @Get('/jobConfig')
    async jobGetConfig(@Query('jobName') jobName) {
        return await this.jobService.jobGetConfig(jobName)
    }

    @ApiOperation({ summary: '删除', description: '说明 : 调用此接口,可删除' })
    @Get('/jobCopy')
    async jobCopy(@Query('jobName') jobName, @Query('formJob') formJob) {

        return await this.jobService.jobCopy(jobName, formJob)
    }

    @ApiOperation({ summary: '删除', description: '说明 : 调用此接口,可删除' })
    @Delete('/jobDestroy')
    async jobDestroy(@Query('jobName') jobName) {
        return await this.jobService.jobDestroy(jobName)
    }


    @ApiOperation({ summary: '删除', description: '说明 : 调用此接口,可删除' })
    @Get('/jobBuild')
    async jobBuild(@Query('jobName') jobName) {
        return await this.jobService.jobBuild(jobName)
    }

    @ApiOperation({ summary: '删除', description: '说明 : 调用此接口,可删除' })
    @Post('/jobDisable')
    async jobDisable(@Query('jobName') jobName) {
        return await this.jobService.jobDisable(jobName)
    }

    @ApiOperation({ summary: '删除', description: '说明 : 调用此接口,可删除' })
    @Get('/jobEnable')
    async jobEnable(@Query('jobName') jobName) {
        return await this.jobService.jobEnable(jobName)
    }

    @ApiOperation({ summary: '删除', description: '说明 : 调用此接口,可删除' })
    @Get('/jobExists')
    async jobExists(@Query('jobName') jobName) {
        return await this.jobService.jobExists(jobName)
    }


}